import { request } from '@/utils/request'
import type { AddArticleDTO, QueryArticleDTO, UpdateArticleDTO, ArticleDTO } from '@/types/article'
import type { PageDTO, PageRes, SortDTO } from '@/types/global'

/**
 * 分页查询用户信息
 * @param params
 */
export function queryArticleList(params: PageDTO & SortDTO & QueryArticleDTO) {
  return request.get<PageRes<ArticleDTO>>('/api/article', { params })
}

export function getArticleById(id: number) {
  return request.get<ArticleDTO>('/api/article/' + id.toString())
}

export function addArticle(data?: AddArticleDTO) {
  return request.post('/api/article', data)
}

export function updateArticle(data: UpdateArticleDTO) {
  return request.put('/api/article', data)
}

export function deleteByIds(idList: any) {
  return request.delete('/api/article', {
    params: {
      idList: idList
    }
  })
}
